"""
Case Type   : 数据库安全特性
Case Name   : 查询enable_risky_query_detection默认值_off
Create At   : 2025/9
Owner       : l1azzzy
Description :
    1、连接数据库
    2、执行show enable_risky_query_detection命令
    3、验证参数默认值
Expect      :
    1、数据库连接成功
    2、命令执行成功
    3、参数值为off,符合预期
History     :
"""

import os
import unittest

from testcase.utils.Common import Common
from testcase.utils.CommonSH import CommonSH
from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger
from yat.test import Node

class SecurityConfigCase0001(unittest.TestCase):

    def setUp(self):
        self.log = Logger()
        self.log.info(f'----{os.path.basename(__file__)} start----')
        self.com = Common('PrimaryDbUser')
        self.constant = Constant()
        self.comsh = CommonSH('PrimaryDbUser')

    def test_risky_query_detection_default(self):
        text = '-----step1:执行show enable_risky_query_detection命令  expect:预期为off-----'
        self.log.info(text)
        sql = 'show enable_risky_query_detection;'
        res = self.comsh.execut_db_sql(sql)
        self.log.info(res)
        self.assertIn('off', res.lower())

    def tearDown(self):
        self.log.info(f'----{os.path.basename(__file__)} end----')